<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

        //父类
        function Person(){
            this.hobby="吃炸鸡";//stu.hobby="吃炸鸡"
            this.play="玩游戏";//stu.play="玩游戏"
        }

        //子类
        function Student(name,age){
            this.name=name;
            this.age=age;
            Person.call(this);//Person.call(stu);
        }
        Student.prototype.say=function(){
            console.log("hello");
        };
        // stu --->Student.prototype --->Object.prototype
        // var stu=new Student("alice",20);
        // console.log(stu);
        // stu.say();
        
        // stu --->Student.prototype ----> Person.prototype--->Object.prototype

        // Student.prototype=Object.create(Person.prototype);
        // Student.prototype.constructor=Student;

        // var stu=new Student("alice",20);
        // console.log(stu);

        
        var u={name:"alice"};
        Student.prototype=Object.create(u);
        Student.prototype.constructor=Student;//如果希望是类型相关的，一定要加constructor属性

        // stu ---->  Student.prototype ----> u----->Object
        var stu=new Student("alice",20);
        console.log(stu);
       
        // - Object.keys()获取对象中所有的可循环的属性名，返回构成属性的列表
        // - Object.values()获取对象中所有的可循环的属性值，返回构成属性的列表
        // - Object.entries()获取对象中所有的可循环的属性名和属性值，返回构成对象形式的列表：[[属性名,属性值],[属性名,属性值],[属性名,属性值]...]
        var arrs=["alice","baby","cici"];
        console.log(Object.keys(arrs));
        console.log(Object.values(arrs));
        console.log(Object.entries(arrs));

    </script>
</head>
<body>
    
</body>
</html>